// // Copyright (c) 2009 All Right Reserved // // vl // // 2009-01-01 // Contains ... using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics.Contracts; using System.Globalization; using System.Text; using JetBrains.Annotations; using LargoCommon.Abstract; namespace LargoCommon.Music { /// Musical material. /// Musical class. //// [Serializable] [ContractVerification(false)] public sealed class MelodicMaterial { #region Constructors /// /// Initializes a new instance of the MelodicMaterial class. /// public MelodicMaterial() { this.Structures = new List(); } /// Initializes a new instance of the MelodicMaterial class. /// Name of the content. [UsedImplicitly] public MelodicMaterial(string name) : this() { this.Name = name; } #endregion #region Properties /// /// Gets or sets the name. /// /// /// The melodic order. /// public string Name { [UsedImplicitly] get; set; } /// /// Gets the structures. /// /// /// The structures. /// public IList Structures { get; } #endregion #region MelodicProducer /// /// Random Melodic Materials. /// /// Number of material sets. /// Melodic structs. /// Number Of Structs. /// Returns value. [UsedImplicitly] public static Collection RandomMelodicMaterials(int number, Collection melStructs, int numberOfStructs) { var coll = new Collection(); for (var i = 0; i < number; i++) { var name = string.Format(CultureInfo.CurrentCulture, "Automatic ({0}) {1}", i.ToString(CultureInfo.CurrentCulture.NumberFormat).PadLeft(3), SupportCommon.DateTimeIdentifier); var melMaterial = RandomMelodicMaterial(name, melStructs, numberOfStructs); coll.Add(melMaterial); } return coll; } #endregion #region String representation /// String representation of the object. /// Returns value. public override string ToString() { var s = new StringBuilder(); //// s.Append("\t" + this.RhythmicOrder.ToString(CultureInfo.CurrentCulture)); //// s.Append("\t" + this.HarmonicOrder.ToString(CultureInfo.CurrentCulture)); return s.ToString(); } #endregion #region MelodicProducer - private /// /// Random Melodic Material. /// /// Name of material. /// Melodic Structs. /// Number Of Structs. /// /// Returns value. /// private static MelodicMaterial RandomMelodicMaterial(string name, Collection melStructs, int numberOfStructs) { Contract.Requires(name != null); //// var dc = this.GetDataContext; var melMaterial = new MelodicMaterial { Name = name }; if (melStructs == null) { return melMaterial; } for (var im = 0; im < numberOfStructs; im++) { var ms = ExtendCollection.GetRandomObject(melStructs); if (ms == null) { continue; } var mms = ms; //// Clone? melMaterial.Structures?.Add(mms); } return melMaterial; } #endregion } }